<template>
  <div>
    <div
      style="font-size: 16px;font-weight: 500;color: #1D2129;margin-bottom: 16px;"
    >
      体校类别
    </div>

    <div style="display: flex; ">
      <img
        src="@/assets/img/Frame@2x.png"
        alt=""
        style="width: 32px;height: 32px; margin-right: 16px;18px;margin-top: 5px"
      />
      <div>
        <div style="font-size: 24px;color: #0F0F0F;">34,201</div>
        <div style="font-size: 12px;">全国体育传统项目学校数量/所</div>
      </div>
    </div>
    <div
      style="height: 40px;width: 100%;background: #F9F9F9;line-height: 40px;margin-top: 16px;"
    >
      <div style="font-size: 12px;color: #165DFF;margin-left: 20px;">
        学校所属重点学校类型
      </div>
    </div>
    <div style="display: flex;">
      <div id="Chart" style="width:40%;height:160px"></div>
      <div
        style="width:60%;height:160px;padding: 31px 16px; display: flex; flex-wrap: wrap;justify-content: space-between;"
      >
        <div style="display: flex;">
          <div style="width:7px;height:7px;background: #4E88F5;"></div>
          <div>
            <div style="font-size: 12px;margin-right: 7px;">
              省级重点(示范校)
            </div>
            <div style="font-size: 22px;color: #0F0F0F;">34,201</div>
          </div>
        </div>
        <div style="display: flex;">
          <div style="width:7px;height:7px;background: #4E88F5;"></div>
          <div>
            <div style="font-size: 12px;margin-right: 7px;">
              省级重点(示范校)
            </div>
            <div style="font-size: 22px;color: #0F0F0F;">34,201</div>
          </div>
        </div>
        <div style="display: flex;">
          <div style="width:7px;height:7px;background: #4E88F5;"></div>
          <div>
            <div style="font-size: 12px;margin-right: 7px;">
              省级重点(示范校)
            </div>
            <div style="font-size: 22px;color: #0F0F0F;">34,201</div>
          </div>
        </div>
        <div style="display: flex;">
          <div style="width:7px;height:7px;background: #4E88F5;"></div>
          <div>
            <div style="font-size: 12px;margin-right: 7px;">
              省级重点(示范校)
            </div>
            <div style="font-size: 22px;color: #0F0F0F;">34,201</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import * as echarts from "echarts";

export default {
  name: "SchoolType",
  data() {
    return {
      chartInstance: null
    };
  },
  mounted() {
    this.datalist();
  },

  methods: {
    datalist() {
      // 基于准备好的dom，初始化echarts实例
      var myChart = echarts.init(document.getElementById("Chart"));
      // 指定图表的配置项和数据
      var option;
      option = {
        title: {
          text: "中心文字",
          left: "center",
          top: "42%",
          textStyle: {
            color: "#333",
            fontSize: 15,
            align: "center"
          }
        },
        tooltip: {
          trigger: "item"
        },

        legend: {
          top: "5%",
          left: "center",
          show: false
        },
        series: [
          {
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            label: {
              show: false,
              position: "center"
            },
            radius: ["65%", "80%"],

            labelLine: {
              show: false
            },
            data: [
              { value: 1048, name: "省级重点(示范校)" },
              { value: 735, name: "地市级级重点(示范校)" },
              { value: 580, name: "区县级重点(示范校)" },
              { value: 484, name: "普通学校" }
            ]
          }
        ]
      };
      // 使用刚指定的配置项和数据显示图表。
      myChart.setOption(option);
      // 监听父元素大小变化 刷新图表
      var ro = new ResizeObserver(entries => {
        for (let entry of entries) {
          const cr = entry.contentRect;
          myChart.resize();
        }
      });
      ro.observe(Chart);
    }
  }
};
</script>

<style scoped>
h2 {
  margin-bottom: 20px;
}
</style>
